package Xiaofang;

import java.io.*;

public class Work01 {
    public static void main(String[] args) {
        int num=0;
        BufferedWriter bw=null;
        System.out.println(System.getProperty("file.encoding"));
        try {
            bw=new BufferedWriter(new FileWriter("D:\\Xiaofang\\xiaofang.txt"));
            for (int i=2;i<10000;i++){
                boolean flag=true;
                for (int j=i;j<2;j++){
                    if(i%j==0){
                        flag=false;
                        break;
                    }
                }
                if(flag){
                    bw.write(i+" ");
                    num++;
                    if(num%10==0){
                        bw.newLine();
                    }
                }
            }
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            try {
                bw.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
